package swag.t;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.widget.Toast;

public class EvilDoer {

	private int x,y,radius,color,health,speed,regen,power;

	private float xvel, yvel;

	private Bitmap img;
	
	private Context cxt;

	
	boolean istouchingevildoer;
	public EvilDoer(int x, int y, float xvel, float yvel, int color, int radius, Context context, int Drawable)
	{
		this.x = x;
		this.y =y;
		this.cxt = context;
		this.color = color;
		this.xvel = xvel;
		this.yvel = yvel;
		this.radius = radius;
		
		BitmapFactory.Options ops = new BitmapFactory.Options();
		ops.inJustDecodeBounds = true;
		Bitmap temp = BitmapFactory.decodeResource(context.getResources(),Drawable);
		img=Bitmap.createScaledBitmap(temp, radius * 2, radius * 2, false);
		
	}

	
	
	
	
	
	
	
	
	
public Bitmap getImage()
{
	return img;
	
}
public void move(float f, float g, Ball ball1)
{
	boolean cont=false;
	//System.out.println(img.getWidth());
	if(x-radius<=0 || (x+ radius)>=480)
	{
		xvel = -xvel;
		while(!cont){
				if((x-radius)<0||(x+radius)>725){
			x+=xvel;
		}else{
			cont = true;
		}
		}
		
	}
	if((y-radius)<=0 || (y+ radius)>=725)
	{
		cont = false;
		yvel = -yvel;

		while(!cont){
				if((y-radius)<0||(y+radius)>725){
			y+=yvel;
		}else{
			cont=true;
		}
		}
	}
	if(Math.abs(ball1.getx()-x)<(ball1.getradius()+5) && Math.abs(y-ball1.gety())<(ball1.getradius()+5))
	{
		if(istouchingevildoer == false)
		{
			istouchingevildoer = true;
			ball1.loselife();
			Toast.makeText(cxt, "You have " + ball1.getLives() + " Lives"  , Toast.LENGTH_SHORT).show();
		
		}
		
		
	}
	
	else 
	{
		istouchingevildoer = false;
	}
	x+=xvel;
	y+=yvel;
	
 
}

public void setX(int x2)
{
 x =x2;	
}

public void setY(int y2)
{
y = y2;
}

public void setRadius(int radius2)
{
	radius = radius2;
}

public int getradius()
{
return radius;
}

public int gety()
{
	return y;
}

public int getx()
{ return x;
}

public void sethealth(int health2)
{
	health = health2;
}

public int gethealth()
{
	return health;
}

public void setspeed(int speed2)
{
	speed = speed2;
}

public int getspeed()
{
	return speed;
}

public void setregen(int regen2)
{
	regen = regen2;
}

public int getregen()
{
	return regen;
}

public void setpower(int power2)
{
	power = power2;
}

public int getpower()
{
	return power;
}


public void setxvel(float xvel2)
{
	 xvel = xvel2;
}
public float getxvel()
{
	return xvel;
}
public void setyvel(float yvel2)
{yvel = yvel2;
}

public float getyvel()
{
	return yvel;
}
public void setcolor(int color2)
{
	color = color2;
}

public int getcolor()
{
	return color;
}


}


	

	
	
	
	

